// 此文件将数据结构进行补全

import Vue from 'vue'
export function completionFunc(fundInfo, title) {
	const data = JSON.parse(JSON.stringify(fundInfo))

	if (!data.productFundApply || ['成立', '查看'].includes(title)) {
		data.productFundApply = {}
		data.dataStatus = '1' // 当没有申请表数据对象时
	} else {
		data.dataStatus = '0' // 当有申请表数据对象时
	}

	/* 补全fundCustodianInfo*/
	if (!data.fundCustodianInfo) {
		data.fundCustodianInfo = {}
	}
	if (!data.fundCustodianInfo.checkLiableId) {
		data.fundCustodianInfo.checkLiableId = ''
	}
	if (!data.fundCustodianInfo.checkLiableName) {
		data.fundCustodianInfo.checkLiableName = ''
	}
	if (!data.fundCustodianInfo.fundSysCode) {
		data.fundCustodianInfo.fundSysCode = ''
	}
	if (!data.fundCustodianInfo.personLiableId) {
		data.fundCustodianInfo.personLiableId = ''
	}
	if (!data.fundCustodianInfo.personLiableName) {
		data.fundCustodianInfo.personLiableName = ''
	}

	if (!data.recordFundAddInfo) {
		data.recordFundAddInfo = {}
	} else {
		if (Object.prototype.toString.call(data.recordFundAddInfo).substring(8, Object.prototype.toString.call(data.recordFundAddInfo).length - 1) !== 'Object') {
			data.recordFundAddInfo = {}
		}
	}

	/* 补全基金经理*/
	if (!data.fundManagerApplyList) {
		data.fundManagerApplyList = JSON.parse(JSON.stringify([]))
	}
	if (!data.fundManagerInfoList) {
		data.fundManagerApplyList = JSON.parse(JSON.stringify([]))
	}

	/* 补全recordFundChangeInfo*/
	if (!data.recordFundChangeInfo) {
		data.recordFundChangeInfo = {}
	}

	/* 补全主表和申请表*/
	if (!data.productFundInfo) {
		data.productFundInfo = {}
	}

	/* 补全基础信息*/
	const baseInfoKeys = [{
		key: 'personLiableName',
		type: 'str'
	}, // 责任人
	{
		key: 'isInnovateNature',
		type: 'str'
	}, // 是否具备创新属性
	{
		key: 'innovateNatureRemark',
		type: 'str'
	},
	{
		key: 'newspaperId',
		type: 'str'
	},
	{
		key: 'fundCode',
		type: 'str'
	},
	{
		key: 'fundName',
		type: 'str'
	},
	{
		key: 'fundFullName',
		type: 'str'
	},
	{
		key: 'fundEnglishName',
		type: 'str'
	},
	{
		key: 'productBrand',
		type: 'str'
	},
	{
		key: 'productPeriod',
		type: 'str'
	},
	{
		key: 'evolveBeforeCode',
		type: 'str'
	},
	{
		key: 'approvalSymbol',
		type: 'str'
	},
	{
		key: 'operateMode',
		type: 'str'
	},
	{
		key: 'openFrequency',
		type: 'str'
	},
	{
		key: 'openFrequencyRemark',
		type: 'str'
	},
	{
		key: 'fiduciaryDuty',
		type: 'str'
	},
	{
		key: 'expectRaiseAmount',
		type: 'str'
	},
	{
		key: 'settleCurrency',
		type: 'str'
	},
	{
		key: 'faceValue',
		type: 'str'
	},
	{
		key: 'fundType',
		type: 'str'
	},
	{
		key: 'mixedInvestBias',
		type: 'str'
	},
	{
		key: 'pobcFundType',
		type: 'str'
	},
	{
		key: 'isHoldFund',
		type: 'str'
	},
	{
		key: 'oneYardPassAccount',
		type: 'str'
	},
	{
		key: 'riskGrade',
		type: 'str'
	},
	{
		key: 'performanceBaseline',
		type: 'str'
	},
	{
		key: 'isListTransfer',
		type: 'str'
	},
	{
		key: 'isQdii',
		type: 'str'
	},
	{
		key: 'isIndexFund',
		type: 'str'
	},
	{
		key: 'isBreakeven',
		type: 'str'
	},
	{
		key: 'isGradFund',
		type: 'str'
	},
	{
		key: 'isMutualFund',
		type: 'str'
	},
	{
		key: 'isActiveManage',
		type: 'str'
	},
	{
		key: 'managerStyle',
		type: 'str'
	},
	{
		key: 'issuerEarlyTermFlag',
		type: 'str'
	},
	{
		key: 'usufructTransferProductFlag',
		type: 'str'
	},
	{
		key: 'currencyMarketFundFlag',
		type: 'str'
	},
	{
		key: 'isAddcreditMeasure',
		type: 'str'
	},
	{
		key: 'isMom',
		type: 'str'
	},
	{
		key: 'revenueFeature',
		type: 'str'
	},
	{
		key: 'isSubAssets',
		type: 'str'
	},
	{
		key: 'momFundCode',
		type: 'str'
	},
	{
		key: 'isNetWorthProduct',
		type: 'str'
	},
	{
		key: 'valuationWay',
		type: 'str'
	},
	{
		key: 'valuationFrequency',
		type: 'str'
	},
	{
		key: 'isRiskTacticsFund',
		type: 'str'
	},
	{
		key: 'isRiskTacticsFund',
		type: 'str'
	},
	{
		key: 'ensureObligorCode',
		type: 'str'
	},
	{
		key: 'ensureObligorName',
		type: 'str'
	},
	{
		key: 'isMarketTrade',
		type: 'str'
	},
	{
		key: 'marketFundType',
		type: 'str'
	},
	{
		key: 'marketTradeSite',
		type: 'str'
	},
	{
		key: 'isPensionTargetFund',
		type: 'str'
	},
	{
		key: 'investTactics',
		type: 'str'
	},
	{
		key: 'isEtfJoinFund',
		type: 'str'
	},
	{
		key: 'targetFundCode',
		type: 'str'
	},
	{
		key: 'targetFundName',
		type: 'str'
	},
	{
		key: 'isOrganCustom',
		type: 'str'
	},
	{
		key: 'organCustom',
		type: 'str'
	},
	{
		key: 'isSingleShare',
		type: 'str'
	},
	{
		key: 'isSponsoredFund',
		type: 'str'
	},
	{
		key: 'sponsoredSelfCapital',
		type: 'str'
	},
	{
		key: 'sponsoredAgreedTerm',
		type: 'str'
	},
	{
		key: 'isFofFund',
		type: 'str'
	},
	{
		key: 'establishScale',
		type: 'str'
	},
	{
		key: 'productAssetReportType',
		type: 'str'
	},
	{
		key: 'branchShareList',
		type: 'arr'
	},
	{
		key: 'noneHKTIsStopApplyRansom',
		type: 'str'
	},
	{
		key: 'crossBorderFinancial',
		type: 'str'
	},
	{
		key: 'propertyFundTrust',
		type: 'str'
	},
	{
		key: 'customerRedemptionFlag',
		type: 'str'
	}
	]
	if (!data.productFundInfo.baseInfo) {
		data.productFundInfo.baseInfo = {}
	}
	if (!data.productFundApply.baseInfo) {
		data.productFundApply.baseInfo = {}
	}
	baseInfoKeys.forEach(item => {
		if (!data.productFundInfo.baseInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundInfo.baseInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundInfo.baseInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
		if (!data.productFundApply.baseInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundApply.baseInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundApply.baseInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
	})
	if (data.productFundInfo.baseInfo.branchShareList.length) {
		data.productFundInfo.baseInfo.branchShareList = data.productFundInfo.baseInfo.branchShareList.filter(item => !!item.subFundType)
	}
	if (data.productFundApply.baseInfo.branchShareList.length) {
		data.productFundApply.baseInfo.branchShareList = data.productFundApply.baseInfo.branchShareList.filter(item => !!item.subFundType)
	}

	/* 补全重要日期信息*/
	const dateInfoKeys = [{
		key: 'approvalDate',
		type: 'str'
	},
	{
		key: 'deferRaiseDate',
		type: 'str'
	},
	{
		key: 'raiseStartDate',
		type: 'str'
	},
	{
		key: 'establishDate',
		type: 'str'
	},
	{
		key: 'logonApprovalChangeDate',
		type: 'str'
	},
	{
		key: 'contractEndDate',
		type: 'str'
	},
	{
		key: 'contractEndDatePeople',
		type: 'str'
	},
	{
		key: 'liquidateAccompleteDate',
		type: 'str'
	},
	{
		key: 'endListDate',
		type: 'str'
	},
	{
		key: 'operateEndDate',
		type: 'str'
	},
	{
		key: 'liquidationStartDate',
		type: 'str'
	},
	{
		key: 'subsistTerm',
		type: 'str'
	},
	{
		key: 'formalEvolveDate',
		type: 'str'
	},
	{
		key: 'nextOpenFirstDate',
		type: 'str'
	},
	{
		key: 'firstRedemptionDate',
		type: 'str'
	},
	{
		key: 'firstRedemptionDate',
		type: 'str'
	}
	]
	if (!data.productFundInfo.dateInfo) {
		data.productFundInfo.dateInfo = {}
	}
	if (!data.productFundApply.dateInfo) {
		data.productFundApply.dateInfo = {}
	}
	dateInfoKeys.forEach(item => {
		if (!data.productFundInfo.dateInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundInfo.dateInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundInfo.dateInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
		if (!data.productFundApply.dateInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundApply.dateInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundApply.dateInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
	})

	/* 补全机构信息*/
	const organInfoKeys = [{
		key: 'managementId',
		type: 'str'
	},
	{
		key: 'fundTaType',
		type: 'str'
	},
	{
		key: 'trusteeId',
		type: 'str'
	},
	{
		key: 'custodyBranchOrganName',
		type: 'str'
	},
	{
		key: 'isThirdPartyCustody',
		type: 'str'
	},
	{
		key: 'investAdvisorId',
		type: 'str'
	},
	{
		key: 'lawId',
		type: 'str'
	},
	{
		key: 'handleLawerName',
		type: 'str'
	},
	{
		key: 'accountFirmId',
		type: 'str'
	},
	{
		key: 'bordersCustodianName',
		type: 'str'
	},
	{
		key: 'bordersCustodianEnglishName',
		type: 'str'
	},
	{
		key: 'bordersAdvisorName',
		type: 'str'
	},
	{
		key: 'bordersAdvisorEnglishName',
		type: 'str'
	},
	{
		key: 'bordersAdvisorEnglishName',
		type: 'str'
	},
	{
		key: 'iscustodyBranchOrgan',
		type: 'str'
	}
	]
	if (!data.productFundInfo.organInfo) {
		data.productFundInfo.organInfo = {}
	}
	if (!data.productFundApply.organInfo) {
		data.productFundApply.organInfo = {}
	}
	organInfoKeys.forEach(item => {
		if (!data.productFundInfo.organInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundInfo.organInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundInfo.organInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
		if (!data.productFundApply.organInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundApply.organInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundApply.organInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
	})

	/* 补全费率信息*/
	const rateInfoKeys = [{
		key: 'feeRateAlgorithm',
		type: 'str'
	},
	{
		key: 'isAchieveReward',
		type: 'str'
	},
	{
		key: 'accrualPointTime',
		type: 'str'
	},
	{
		key: 'rewardExplain',
		type: 'str'
	},
	{
		key: 'accrualDatum',
		type: 'str'
	},
	{
		key: 'accrualRatio',
		type: 'str'
	},
	{
		key: 'accrualRatio',
		type: 'str'
	},
	{
		key: 'feeRateInfoList',
		type: 'arr'
	},
	{
		key: 'custodyFeeAlgorithm',
		type: 'str'
	}
	]
	if (!data.productFundInfo.rateInfo) {
		data.productFundInfo.rateInfo = {}
	}
	if (!data.productFundApply.rateInfo) {
		data.productFundApply.rateInfo = {}
	}
	rateInfoKeys.forEach(item => {
		if (!data.productFundInfo.rateInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundInfo.rateInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundInfo.rateInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
		if (!data.productFundApply.rateInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundApply.rateInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundApply.rateInfo[item.key] = JSON.parse(JSON.stringify([]))
			}
		}
	})
	const listapply = rateListFunc(
		data.productFundApply.rateInfo.feeRateInfoList || [],
		data.productFundApply.baseInfo.branchShareList || []
	)
	data.productFundApply.rateInfo.feeRateInfoList = JSON.parse(JSON.stringify(listapply))

	const listinfo = rateListFunc(
		data.productFundInfo.rateInfo.feeRateInfoList,
		data.productFundInfo.baseInfo.branchShareList
	)
	data.productFundInfo.rateInfo.feeRateInfoList = JSON.parse(JSON.stringify(listinfo))

	/* 补全投资相关信息*/
	const investInfoKeys = [{
		key: 'specialTypeChar',
		type: 'str'
	},
	{
		key: 'isContainSpclLimit',
		type: 'str'
	},
	{
		key: 'specialTypeName',
		type: 'str'
	},
	{
		key: 'spclLimitRemark',
		type: 'str'
	},
	{
		key: 'isQuantTactics',
		type: 'str'
	},
	{
		key: 'isCoverTactics',
		type: 'str'
	},
	{
		key: 'stockMinRatio',
		type: 'str'
	},
	{
		key: 'stockMaxRatio',
		type: 'str'
	},
	{
		key: 'bondMinRatio',
		type: 'str'
	},
	{
		key: 'bondMaxRatio',
		type: 'str'
	},
	{
		key: 'currencyMinRatio',
		type: 'str'
	},
	{
		key: 'currencyMaxRatio',
		type: 'str'
	},
	{
		key: 'hkStockMaxRatio',
		type: 'str'
	},
	{
		key: 'remark',
		type: 'str'
	}
	]
	if (!data.productFundInfo.investInfo) {
		data.productFundInfo.investInfo = {}
	}
	if (!data.productFundApply.investInfo) {
		data.productFundApply.investInfo = {}
	}
	investInfoKeys.forEach(item => {
		if (!data.productFundInfo.investInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundInfo.investInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundInfo.investInfo[item.key] = []
			}
		}
		if (!data.productFundApply.investInfo[item.key]) {
			if (item.type === 'str') {
				data.productFundApply.investInfo[item.key] = ''
			} else if (item.type === 'arr') {
				data.productFundApply.investInfo[item.key] = []
			}
		}
	})

	/* 补全文件信息*/
	if (!data.productFundInfo.fundFileInfo) {
		data.productFundInfo.fundFileInfo = {}
	}
	if (!data.productFundApply.fundFileInfo) {
		data.productFundApply.fundFileInfo = {}
	}

	return data
}

// 如果哪天你维护到这段代码，建议轻易不要动
// 补全费率数组
/*
rate 费率列表
branchShareList 下属基金列表
fundCode 基金代码
*/
export function rateListFunc(rate, branchShareList) {
	let feeRateInfoList = []
	let feeRateInfoList2 = []
	let rateList = []

	const branchShare = JSON.parse(JSON.stringify(branchShareList.filter(item => !!item.subFundType)))
	if (branchShare.length) {
		feeRateInfoList = jsonArray(rate.filter(item => !!item.subFundType))
	} else {
		feeRateInfoList = jsonArray(rate)
	}
	feeRateInfoList2 = jsonArray(rate)
	const manageRate = feeRateInfoList2.filter(item => item.feeRateType === '9').splice(0, 1) // 处理管理费率
	if (!manageRate.length) {
		manageRate.push({
			feeRateUnit: '1',
			feeRate: '',
			feeRateType: '9',
			feeRateId: 1,
			remark: ''
		})
	}
	const trusteeRate = feeRateInfoList2.filter(item => item.feeRateType === '7').splice(0, 1) // 处理托管费率
	if (!trusteeRate.length) {
		trusteeRate.push({
			feeRateUnit: '1',
			feeRate: '',
			feeRateType: '7',
			feeRateId: 1,
			remark: ''
		})
	}

	rateList = [...jsonArray(rateList), ...jsonArray(manageRate), ...jsonArray(trusteeRate)]
	if (branchShare.length) { // 有下属基金
		branchShare.forEach(items => {
			if (items.subFundType === '1') { // A类
				const salesSerivceRateList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '8' && item.subFundType === '1'), '1', '8', items.fundCode, 1) // 处理销售服务费率
				const branchSubRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '1' && item.subFundType === '1'), '1', '1', items.fundCode, 4) // 处理普通认购费率
				const branchSubCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '2' && item.subFundType === '1'), '1', '2', items.fundCode, 4) // 处理直销中心认购费率
				const branchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '3' && item.subFundType === '1'), '1', '3', items.fundCode, 4) // 前端-处理普通申购费率
				const rearRndBranchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '10' && item.subFundType === '1'), '1', '10', items.fundCode, 4) // 后端-处理普通申购费率
				const branchApplyCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '4' && item.subFundType === '1'), '1', '4', items.fundCode, 4) // 前端-处理通过直销中心申购费率
				const rearRndBranchApplyCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '11' && item.subFundType === '1'), '1', '11', items.fundCode, 4) // 后端-处理通过直销中心申购费率
				const branchRansomRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '5' && item.subFundType === '1'), '1', '5', items.fundCode, 6) // 处理普通赎回费率
				rateList = [
					...jsonArray(rateList),
					...jsonArray(salesSerivceRateList),
					...jsonArray(branchSubRateListList),
					...jsonArray(branchSubCntListList),
					...jsonArray(branchApplyRateListList),
					...jsonArray(rearRndBranchApplyRateListList),
					...jsonArray(branchApplyCntListList),
					...jsonArray(rearRndBranchApplyCntListList),
					...jsonArray(branchRansomRateListList)
				]
			} else { // 其他类
				const salesSerivceRateList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '8' && item.subFundType === items.subFundType), items.subFundType, '8', items.fundCode, 1) // 处理销售服务费率
				const branchSubRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '1' && item.subFundType === items.subFundType), items.subFundType, '1', items.fundCode, 4) // 处理普通认购费率
				const branchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '3' && item.subFundType === items.subFundType), items.subFundType, '3', items.fundCode, 4) // 前端-处理普通申购费率
				const rearRndBranchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '10' && item.subFundType === items.subFundType), items.subFundType, '10', items.fundCode, 4) // 后端-处理普通申购费率
				const branchRansomRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '5' && item.subFundType === items.subFundType), items.subFundType, '5', items.fundCode, 6) // 处理普通赎回费率
				rateList = [
					...jsonArray(rateList),
					...jsonArray(salesSerivceRateList),
					...jsonArray(branchSubRateListList),
					...jsonArray(branchApplyRateListList),
					...jsonArray(rearRndBranchApplyRateListList),
					...jsonArray(branchRansomRateListList)
				]
			}
		})
	} else { // 无下属基金
		const salesSerivceRateList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '8'), '', '8', '', 1) // 处理销售服务费率
		const branchSubRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '1'), '', '1', '', 4) // 处理普通认购费率
		const branchSubCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '2'), '', '2', '', 4) // 处理直销中心认购费率
		const branchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '3'), '', '3', '', 4) // 前端-处理普通申购费率
		const rearRndBranchApplyRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '10'), '', '10', '', 4) // 后端-处理普通申购费率
		const branchApplyCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '4'), '', '4', '', 4) // 前端-处理通过直销中心申购费率
		const rearRndBranchApplyCntListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '11'), '', '11', '', 4) // 后端-处理通过直销中心申购费率
		const branchRansomRateListList = spliceIsPush(feeRateInfoList.filter(item => item.feeRateType === '5'), '', '5', '', 6) // 处理普通赎回费率
		rateList = [
			...jsonArray(rateList),
			...jsonArray(salesSerivceRateList),
			...jsonArray(branchSubRateListList),
			...jsonArray(branchSubCntListList),
			...jsonArray(branchApplyRateListList),
			...jsonArray(rearRndBranchApplyRateListList),
			...jsonArray(branchApplyCntListList),
			...jsonArray(rearRndBranchApplyCntListList),
			...jsonArray(branchRansomRateListList)
		]
	}
	rateList.forEach(item => {
		item.startSection = item.startSection ? item.startSection : ''
	})

	// 如果没有下属基金就删除掉基金代码
	if (!branchShare.length) {
		rateList.forEach((item) => {
			Vue.delete(item, 'fundCode')
		})
	}

	rateList.forEach(item => {
		const keys = Object.keys(item)
		keys.forEach(items => {
			if (!item[items]) {
				item[items] = ''
			}
		})
		if (item.feeRateType === '5') {
			item.belongFundRatio = item.belongFundRatio ? item.belongFundRatio : ''
			item.belongFundRatioUnit = item.belongFundRatioUnit ? item.belongFundRatioUnit : '1'
			item.remark = item.remark ? item.remark : ''
		}
		if (item.feeRateType !== '5') {
			if ('belongFundRatio' in item) {
				Vue.delete(item, 'belongFundRatio')
			}
			if ('belongFundRatioUnit' in item) {
				Vue.delete(item, 'belongFundRatioUnit')
			}
			item.remark = item.remark ? item.remark : ''
		}
		if (['1', '2', '3', '4'].includes(item.feeRateType)) {
			item.itemSign = 'M'
		}
		if (['5', '6', '10', '11'].includes(item.feeRateType)) {
			item.itemSign = 'N'
		}
	})

	return jsonArray(rateList)
}

// 处理费率数组
// rate 要处理的数组
// subFundType 下属基金类型
// rateType 费率类型
// fundCode 基金代码
// type 数组长度类型
function spliceIsPush(rate, subFundType, rateType, fundCode, type) {
	const list = [...JSON.parse(JSON.stringify(rate))]
	let rateArray = []
	if (type === 4) { // 长度为4的类型的数组
		if (list.length > 4) {
			rateArray = JSON.parse(JSON.stringify(list.filter((item, index) => index < 4)))
		} else if (list.length < 4) {
			const addLength = list.length
			for (let i = addLength; i < 4; i++) {
				let j = 1
				j += i
				const obj = {
					feeRateType: rateType,
					feeRateId: `${j}`,
					startSection: '',
					endSection: '',
					feeRate: '',
					feeRateUnit: '1',
					subFundType: subFundType,
					fundCode: fundCode
				}
				list.push(JSON.parse(JSON.stringify(obj)))
			}
			rateArray = JSON.parse(JSON.stringify(list))
		} else if (list.length === 4) {
			rateArray = JSON.parse(JSON.stringify(list))
		}
	} else if (type === 6) { // 长度为6的类型的数组
		if (list.length > 6) {
			rateArray = JSON.parse(JSON.stringify(list.filter((item, index) => index < 6)))
		} else if (list.length < 6) {
			const addLength = list.length
			for (let i = addLength; i < 6; i++) {
				let j = 1
				j += i
				const obj = {
					feeRateType: rateType,
					feeRateId: `${j}`,
					startSection: '',
					endSection: '',
					feeRate: '',
					feeRateUnit: '1',
					subFundType: subFundType,
					fundCode: fundCode,
					belongFundRatio: '',
					belongFundRatioUnit: '1'
				}
				list.push(JSON.parse(JSON.stringify(obj)))
			}
			rateArray = JSON.parse(JSON.stringify(list))
		} else if (list.length === 6) {
			rateArray = JSON.parse(JSON.stringify(list))
		}
	} else if (type === 1) {
		if (list.length > 1) {
			rateArray = JSON.parse(JSON.stringify(list.filter((item, index) => index < 1)))
		} else if (list.length < 1) {
			const addLength = list.length
			for (let i = addLength; i < 1; i++) {
				let j = 1
				j += i
				const obj = {
					feeRateType: rateType,
					feeRateId: `${j}`,
					startSection: '',
					endSection: '',
					feeRate: '',
					feeRateUnit: '1',
					subFundType: subFundType,
					fundCode: fundCode
				}
				list.push(JSON.parse(JSON.stringify(obj)))
			}
			rateArray = JSON.parse(JSON.stringify(list))
		} else if (list.length === 1) {
			rateArray = JSON.parse(JSON.stringify(list))
		}
	}

	return JSON.parse(JSON.stringify(rateArray))
}

function jsonArray(list) { // 将数组序列化
	return JSON.parse(JSON.stringify(list))
}
